<?php

class mysqldb {

function setquery($DB, $CONN, $QUERY_STRING,$MODE=0) {
$this->mode=$MODE;
 switch($MODE) {
	case 0: #select
		$this->querystring = $QUERY_STRING;
		$this->database = $DB;
		$this->conn = $CONN;
		$this->executequery();
		break;
	case 1: #insert
		$this->querystring = $QUERY_STRING;
		$this->database = $DB;
		$this->conn = $CONN;
		$this->executequery();
		break;
	case 2: #update
		break;
	case 3: #delete
		$this->querystring = $QUERY_STRING;
		$this->database = $DB;
		$this->conn = $CONN;
		$this->executequery();
		break;
 }
}
function executequery() {
 switch ($this->mode) {
	case 0:#select
	mysql_select_db($this->database, $this->conn);
	$this->query = mysql_query($this->querystring, $this->conn) or die(mysql_error());
	$this->row = mysql_fetch_assoc($this->query);
	$this->totalRows = mysql_num_rows($this->query);
	break;
	case 1: #insert
	mysql_select_db($this->database, $this->conn);
	$this->query = mysql_query($this->querystring, $this->conn) or die(mysql_error());
	$this->lastId = mysql_insert_id($this->conn);
	break;
	case 2: #update > use insert instead
	break;
	case 3: #delete
		mysql_select_db($this->database, $this->conn);
		$this->query = mysql_query($this->querystring, $this->conn) or die(mysql_error());
	break;
 }

}
function disposequery() {
 switch($this->mode) {
	case 0: #select
	mysql_free_result($this->query);
	break;
	default:break;
 }
}


var $database = "none";
var $conn = "none";
var $querystring = "";
var $query = 0;
var $row = "";
var $totalRows = 0;
var $mode = 0;
var $lastId = 0;

}

?>
